package com.gxa.financial.controller;

import com.gxa.common.R;
import com.gxa.common.entity.financial_management.WithdrawalManagement;
import com.gxa.common.entity.financial_management.WithdrawalSetting;
import com.gxa.financial.service.WithdrawalManagementService;
import com.gxa.financial.service.WithdrawalSettingService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/withdrawal")
public class WithdrawalController {

    @Autowired
    private WithdrawalSettingService withdrawalSettingService;

    @Autowired
    private WithdrawalManagementService withdrawalManagementService;

    //添加提现设置或者修改提现设置
    @PostMapping("/addWithdrawalSetting")
    public R addWithdrawalSetting(@RequestBody WithdrawalSetting withdrawalSetting){
        return withdrawalSettingService.addWithdrawalSetting(withdrawalSetting);
    }

    //根据用户类型查询详情
    @GetMapping("/selectWithdrawalSetting")
    public R selectWithdrawalSetting(Byte accountType){
        return withdrawalSettingService.selectWithdrawalSetting(accountType);
    }

    //提现管理分页
    @GetMapping("/selectWithdrawalList")
    public R selectWithdrawalList(Integer currentPage, Integer pageSize){
        return withdrawalManagementService.selectWithdrawalList(currentPage,pageSize);
    }

    //提现管理条件查询
    @GetMapping("/selectWithdrawal")
    public R selectWithdrawal(Integer currentPage, Integer pageSize, WithdrawalManagement withdrawalManagement){
        return withdrawalManagementService.selectWithdrawal(currentPage,pageSize,withdrawalManagement);
    }

    //


    //添加提现交易
    @PostMapping("/addWithdrawal")
    public R addWithdrawal(WithdrawalManagement withdrawalManagement){
        return withdrawalManagementService.addWithdrawal(withdrawalManagement);
    }

    //根据交易号查询详情
    @GetMapping("/selectWithdrawalByNo")
    public R selectWithdrawalByNo(Long transactionNo){
        return withdrawalManagementService.selectWithdrawalByNo(transactionNo);
    }

    //提现结果
    @PostMapping("/updateWithdrawalByNo")
    public R updateWithdrawalByNo(WithdrawalManagement withdrawalManagement){
        return withdrawalManagementService.updateWithdrawalByNo(withdrawalManagement);//id,处理人，原因
    }

    //到处excel表格
    @GetMapping("/export")
    public void export(HttpServletRequest request, HttpServletResponse response){
        withdrawalManagementService.export(request,response);
    }

}
